package com.merchant.document.entity;

public class Result<T> {

    private boolean success;

    private String msg;

    private int code;

    private T data;

    public Result() {

    }

    public Result(T data) {
        this(true);
        this.data = data;
    }

    public Result(boolean success) {
        this.code = success ? 200 : 500;
        this.msg = "请求成功";
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Result(boolean success, String message) {
        this(success);
        this.msg = message;
    }

    public Result(boolean success, String message, T data) {
        this(success, message);
        this.data = data;
    }

    public Result(boolean success, String message, int code, T data) {
        this(success, message, data);
        this.code = code;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Result{" +
                "success=" + success +
                ", message='" + msg + '\'' +
                ", code=" + code +
                ", data=" + data +
                '}';
    }
}
